#include <iostream>

#include <vector>
using namespace std;
int main(){
    int n; cin >> n;
    std::vector<long long> prefix(n+1, 0);
    int a = 0;
    for(int i = 0; i < n; ++i)
    {
        cin >> a;
        prefix[i+1] = prefix[i] + a;
    }
    int m; cin >> m;

    while(m--){
        int left,right; cin >> left >> right;

        std::cout << prefix[right] - prefix[left - 1] << std::endl;
    }
    return 0;
}

int main1(){
    int n; std::cin >> n;
    std::vector<int> vec(n);
    for(auto &item:vec){
        std::cin >> item;
    }
    int m; std::cin >> m;
    while(m--){
        int sum = 0;
        int left,end; std::cin >> left >> end;
        for(int i = left; i >= 1 && end <=n && i <= end; ++i){
            sum += vec[i-1];
        }
        std::cout << sum << std::endl;
    }

    return 0;
}